-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AWS] [S3] fix: improve object size metric calculation #41755
base: main
Are you sure you want to change the base?
[AWS] [S3] fix: improve object size metric calculation #41755
Conversation
Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services) |
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
78c0c74
to
04531f3
Compare
Signed-off-by: Kavindu Dodanduwa <[email protected]>
@@ -36,7 +36,7 @@ func init() { | |||
// currentTime returns the current time. This exists to allow unit tests | |||
// simulate the passage of time. | |||
func currentTime() time.Time { | |||
clock := clockValue.Load().(clock) | |||
clock, _ := clockValue.Load().(clock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - had to fix this to get lint correct
totalBytesRead *monitoring.Uint | ||
|
||
trackBytes int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the naming could be more clear. "trackBytes" does not mean much to me. Maybe...
totalBytesReadMetric *monitoring.Uint
totalBytesRead int64
return n, err | ||
} | ||
|
||
func (m *monitoredReader) GetTrackedBytes() int64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The accessor seems unnecessary. The caller can read straight from the field.
Proposed commit message
This fixes a bug with Cloudflare logpush integration, which uses the S3 input.
#40775 introduced a feature introducing s3_object_size_in_bytes histogram. Internally it utilized S3 SDK's GetObjectOutput instances' ContentLength property 1. In code level (SDK internally), this is derived using Content-Length header 2.
It seems that Cloudflare R2 (API compatible with S3) could omit Content-Length header 3. Hence, I have improved how we derive the
s3_object_size_in_bytes
metric by avoiding using Content-Length backed method.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Screenshots
See metric comparison with proposed collection method (before removing content length usage). Tracked total bytes are same as content length.
Handling validated for gzip
Handling validated for plain text
Footnotes
https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_ResponseSyntax ↩
https://github.com/aws/aws-sdk-go-v2/blob/service/s3/v1.60.1/service/s3/deserializers.go#L5477-L5484 ↩
https://community.cloudflare.com/t/no-content-length-header-when-serving-plaintext-from-r2/565521 ↩